#ifndef FILEINFO_H
#define FILEINFO_H

#include "vl/VLd.h"
#include <string>
#include <string.h>
#include "moremath.h"
#include "FunctionGraph.h"
#include <cassert>

class Model;

class FileInfo
{
public:
	enum FileType{ DEFAULT, MODEL, DOF, C3D }; 
protected:
	FileType mType;
	bool mIsActive;
	int mIndex;
	int mNumFrames;
	char mFileName[256];
	char mFilePath[256];
	char mFileNameComplete[512];
	Vec4d mColor;
	bool mHide;	// draw or not
	double mFPS; //different file may have different frame rate; can be used to do time wrap
	Model* mModel;
	vector< FunctionGraph* > mGraphs; 
public:
	FileInfo( FileType _type=DEFAULT, double _fps=30.0){
		mIsActive = false;
		mIndex = -1;
		mNumFrames = 0;
		mFileName[0]='\0';
		mColor = Vec4d(moremath::random(0.5,1.0), moremath::random(0.5,1.0), moremath::random(0.5,1.0), 1.0);
		mType = _type;
		mModel = NULL;
		mFPS = _fps;
		mHide=false;
	}
	virtual ~FileInfo(){ 
		for(int i=0; i<mGraphs.size(); i++)
			delete mGraphs[i];
		mGraphs.clear();
	}
	inline void hide(){mHide=true;}
	inline void show(){mHide=false;}
	inline bool isVisible(){return !mHide;}

	inline Vec4d getColor(){return mColor;}
	inline void setColor(Vec4d _c){mColor = _c;}
	virtual void draw( int _frame, bool _default=true ){}
	virtual void drawHandles( int _frame, bool _default=true){}
	virtual void drawConstr( int _frame, bool _default=true ){}
	virtual bool loadFile(char* _fileName)=0;
	virtual bool saveFile(char*, int, int){return false;}
	virtual void createGraphs(){}
	inline virtual void setFPS(double _fps){ mFPS = _fps; }

	inline bool isActive(){ return mIsActive; }
	inline void setActive( bool _active ){ mIsActive = _active; }
	inline int getIndex(){ return mIndex; }
	inline void setIndex(int _idx) { mIndex = _idx; }
	inline int getNumFrames(){ return mNumFrames; }
	inline char* getFileName(){ return mFileName; }
	inline char* setFileName( const char* _fName ){ strcpy(mFileName, _fName); return getFileName();}
	inline char* getFilePath(){ return mFilePath; }
	inline char* getFullFileName(){
		strcpy(mFileNameComplete, (string(mFilePath)+"/"+string(mFileName)).c_str());
		return mFileNameComplete;
	}
	inline char* setFilePath( const char* _fName ){ strcpy(mFilePath, _fName); return getFilePath();}
	inline FileType getType(){ return mType; }
	inline int getNumGraphs(){ return static_cast<int>(mGraphs.size()); }
	inline FunctionGraph* getGraphAt(int i){ assert(i>=0 && i<mGraphs.size()); return mGraphs[i]; }
	inline Model* getModel(){ return mModel; }
	inline void setModel(Model* _m){ mModel = _m; }
	inline double getFPS(){ return mFPS; }
};

#endif
